﻿using System;
using System.Collections.Generic;

using System.Text;

namespace DataProvider.DBAttribute
{
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class DBField : Attribute
    {
        private String filedName = "";
        private bool onlySelect = false;
        private bool isPrimaryKey = false;
        private bool idAutoIncrease = false;
        private DBFieldType fieldType= DBFieldType.Varchar;
        public DBField()
        {
        }
        public DBField(String fieldName)
        {
            this.filedName = fieldName;
        }

        public DBField(String fieldName, bool onlySelect)
        {
            this.filedName = fieldName;
            this.onlySelect = onlySelect;
        }

        public DBField(String fieldName, bool onlySelect,bool isPrimaryKey)
        {
            this.filedName = fieldName;
            this.onlySelect = onlySelect;
            this.isPrimaryKey = isPrimaryKey;
        }

        public DBField(String fieldName, bool isPrimaryKey, DBFieldType fieldType, bool idAutoIncrease)
        {
            this.filedName = fieldName;
            this.isPrimaryKey = isPrimaryKey;
            this.fieldType = fieldType;
            if (isPrimaryKey == false)
            {
                this.idAutoIncrease = false;
            }
            else
            {
                this.idAutoIncrease = idAutoIncrease;
            }
        }

        public bool OnlySelect
        {
            get
            {
                return this.onlySelect;
            }
        }

        public bool IsPrimaryKey
        {
            get
            {
                return this.isPrimaryKey;
            }
        }
        public bool IdAutoIncrease
        {
            get
            {
                return this.idAutoIncrease;
            }
        }

        public String FiledName
        {
            get
            {
                return this.filedName;
            }
        }

        public DBFieldType FieldType
        {
            get
            {
                return this.fieldType;
            }
        }
    }

    public enum DBFieldType
    {
        Int,
        Varchar,
    }
}
